package com.shop.mapper;

import com.shop.entity.Address;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface AddressMapper {

    /**
     * 分页查询用户地址
     * @param pageNum 页码
     * @param pageSize 每页数量
     * @return
     */
    public List<Address> listAddress(@Param("pageNum")int pageNum, @Param("pageSize") int pageSize);

    List<Address> listWithAddressMappers(@Param("userId") int userId);
    /**
     * 查询用户地址
     * @param userId 用户ID
     * @return
     */
    public Address Address(@Param("userId") int userId);

    /**
     * 添加用户地址
     */
    public void addAddress(Address address);

    /**
     * 修改用户地址
     * @param id
     * @param userId
     * @param receiverName
     * @param phone
     * @param isDefault
     */
    public void updateAddress(@Param("id") int id,
                              @Param("userId") int userId,
                              @Param("receiverName") String receiverName,
                              @Param("phone") String phone,
                              @Param("provinceCityDistrict") String provinceCityDistrict,
                              @Param("detailAddress") String detailAddress,
                              @Param("isDefault") Boolean isDefault);

    /**
     * 删除用户地址
     * @param id 地址ID
     * @param userId 用户ID
     */
    public void deleteAddress(@Param("id") int id );

    /**
     * 获取用户地址总数
     * @return
     */
    public int getTotal();
}
